/**
 *	流程模块接口文件：商品子表
 *	开发者：雨中磐石
 *	地址：www.rockoa.com
 *	日期：2023-07-19
 */

package com.framework.Module.jxc.jxcgoodn;




import com.framerock.db.DB;
import com.framerock.baselib.CallBack;
import com.framerock.baselib.Rock;
import com.framework.Flow.FlowListener;

import java.util.ArrayList;
import java.util.Map;


public class FlowListenerjxcgoodn extends FlowListener {



    @Override
    public Boolean onModejs() {
        return true;
    }

    @Override
    public Boolean onisAdd() {
        return true;
    }

    @Override
    public Boolean onisDelete() {
        return true;
    }

    @Override
    public Boolean onisEdit() {
        return true;
    }

    @Override
    public ArrayList<Map<String, String>> onStore(String action, String params) {
        if(action.equals("spdata"))return spdata();
        return null;
    }

    @Override
    public void onFlowunitadd() {
        mFlow.updateUnit(Rock.getMap("isxs=0"), mFlow.funitid, "");
    }

    //读取商品
    public ArrayList<Map<String, String>> spdata()
    {
        ArrayList<Map<String, String>> rows;
        rows = mFlow.mDBLimit.getData(DB.chuliPerfix("jxcbase"), "`cid`="+mFlow.COMPANYID+"", "id,name,xinghao,guige,price,prices,unit,stock", "`sort` ASC", "", new CallBack(){
            @Override
            public Map<String, String> backMap(Map<String, String> a) {
                String str = a.get("name"),str1 = "";
                str1+=""+a.get("xinghao");
                str1+=""+a.get("guige");
                if(!Rock.isEmpt(str1))str+="("+str1+")";
                a.put("name", str);
                a.put("value", a.get("id"));
                a.put("subname", a.get("stock")+a.get("unit"));
                return a;
            }
        });
        return rows;
    }



}
